
const { executeQuery } = require('./mysql'); // 替换为你的数据库执行模块


async function getMajorNameById(majorId) {
    try {
      const sql = 'SELECT Major_Name FROM tb_major WHERE Major_ID = ?';
      const [rows] = await executeQuery(sql, [majorId]);
  
      if (rows ) {
        return rows.Major_Name; // 返回第一个匹配的 Major_Name
      } else {
        throw new Error(`Major with ID ${majorId} not found.`);
      }
    } catch (error) {
      console.error('Error fetching major name:', error);
      throw error;
    }
}

module.exports = {
    getMajorNameById,
};